package com.adpter;

import java.util.ArrayList;

import android.content.Context;
import android.media.ThumbnailUtils;
import android.provider.MediaStore.Images;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.android.ocean.util.v.Video;
import com.matang.R;
/**
 * 
 * @ClassName:LocalGridAdapter
 * @Description:TODO本地视频列表
 * @author zhuw
 * @date 2013-8-27 上午10:23:31
 */
public class LocalGridAdapter extends CusBaseAdapter {
	Context context;
	ArrayList<Video> list;

	public LocalGridAdapter() {
	}

	public LocalGridAdapter(Context context, ArrayList<Video> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int i) {
		return list.get(i);
	}

	@Override
	public long getItemId(int i) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder vh = null;
		if (view == null) {
			view = LayoutInflater.from(context).inflate(
					R.layout.list_item_video, null);
			vh = new ViewHolder();
			vh.imgView = (ImageView) view.findViewById(R.id.iv);
			view.setTag(vh);
		} else {
			vh = (ViewHolder) view.getTag();
		}
		vh.imgView.setImageBitmap(ThumbnailUtils.createVideoThumbnail(list.get(position).getPath(), Images.Thumbnails.MINI_KIND));
		return view;

	}

	class ViewHolder {
		ImageView imgView;

	}
}
